; *** Small Chess
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com
(translate 
 ("White" "白方")("Black" "黑方")
 ("Pawn" "兵")("Rook" "车")("Weak-Pawn" " 兵")
 ("Bishop" "象")("Queen" "后")
 ("Knight" "马")("King" "王")
 ("MiniChess 5x5" "迷你国际象棋 5x5")
 ("Baby Chess 5x5" "国际象棋 5x5 - 有王车易位，有挺兵")
 ("Opposing Bishops 5x5" "国际象棋 5x5 - 对面象布局")
 ("Knights vs. Bishops 5x5" "国际象棋 5x5 - 马对象布局")
 ("Petty Chess 5x6" "小型国际象棋 5x6")
 ("Los Alamos Chess 6x6" "洛斯阿拉莫斯象棋 6x6")
 ("Knights vs. Bishops 6x6" "国际象棋 6x6 - 马对象布局")
)

; Movement Macros

(define shift          ($1 (verify not-friend?) add) )
(define shift2         ($1 $2 (verify not-friend?) add) )
(define king-shift     ($1 (verify not-friend?) (set-attribute never-moved? false) add) )
(define slide          ($1 (while empty? add $1) (verify not-friend?) add) )
(define Pawn-add       (if (in-zone? promotion-zone) (add Knight Bishop Rook Queen) else add ) )
(define Weak-Pawn-move (n  (verify empty?) (Pawn-add)) )
(define Pawn-capture   ($1 (verify enemy?) (Pawn-add)) )

(define Pawn-move
   (
      n
      (verify empty?)
      (Pawn-add)
      (verify (in-zone? third-rank))
      n
      (verify empty?)
      add
   )
)
(define En-Passant
   (
      $1
      (verify enemy?)
      (verify last-to?)
      (verify (piece? Pawn))
      capture
      n
      to
      n
      (verify last-from?)
      add
   )
)
(define rook-slide
   (
     $1
     (while empty? (set-attribute never-moved? false) add $1)
     (verify not-friend?)
     (set-attribute never-moved? false)
     add
   )
)


; Board Macros

(define board-5x5
   (board
      (image "images\Chess\SHaag\Chess5x5.bmp" "images\Chess\Chess5x5.bmp")
      (grid
         (start-rectangle 5 5 53 53)
         (dimensions
             ("a/b/c/d/e" (49 0)) ; files
             ("5/4/3/2/1" (0 49)) ; ranks
         )
         (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			         (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
         )
      )
      (symmetry Black (n s)(s n) (nw se)(sw ne) (ne sw)(se nw) (e w)(w e)) ; Reverse e-w for Baby Chess castling
      (zone
         (name promotion-zone)
         (players White)
         (positions a5 b5 c5 d5 e5)
      )
      (zone
         (name promotion-zone)
         (players Black)
         (positions a1 b1 c1 d1 e1)
      )
      (zone
         (name third-rank)
         (players White Black)
         (positions a3 b3 c3 d3 e3)
      )
   )
)
(define board-5x6
   (board
      (image "images\Chess\SHaag\Chess5x6.bmp" "images\Chess\Chess5x6.bmp")
      (grid
         (start-rectangle 5 5 53 53)
         (dimensions
             ("a/b/c/d/e" (49 0)) ; files
             ("6/5/4/3/2/1" (0 49)) ; ranks
         )
         (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			         (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
         )
      )
      (symmetry Black (n s)(s n) (nw sw)(sw nw) (ne se)(se ne))
      (zone
         (name promotion-zone)
         (players White)
         (positions a6 b6 c6 d6 e6)
      )
      (zone
         (name promotion-zone)
         (players Black)
         (positions a1 b1 c1 d1 e1)
      )
      (zone
         (name third-rank)
         (players White)
         (positions a3 b3 c3 d3 e3)
      )
      (zone
         (name third-rank)
         (players Black)
         (positions a4 b4 c4 d4 e4)
      )
   )
)


(define board-6x6
   (board
      (image "images\Chess\SHaag\Chess6x6.bmp" "images\Chess\Chess6x6.bmp")
      (grid
         (start-rectangle 5 5 53 53)
         (dimensions
             ("a/b/c/d/e/f" (49 0)) ; files
             ("6/5/4/3/2/1" (0 49)) ; ranks
         )
         (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0)
			         (ne 1 -1) (nw -1 -1) (se 1 1) (sw -1 1)
         )
      )
      (symmetry Black (n s)(s n) (nw sw)(sw nw) (ne se)(se ne))
      (zone
         (name promotion-zone)
         (players White)
         (positions a6 b6 c6 d6 e6 f6)
      )
      (zone
         (name promotion-zone)
         (players Black)
         (positions a1 b1 c1 d1 e1 f1)
      )
      (zone
         (name third-rank)
         (players White)
         (positions a3 b3 c3 d3 e3)
      )
      (zone
         (name third-rank)
         (players Black)
         (positions a4 b4 c4 d4 e4)
      )
   )
)
(define O-O
	 ( (verify never-moved?)
	   e ; KB1
	   (verify empty?)
	   e ; KN1
	   (verify empty?)
	   cascade
	   e ; KR1
	   (verify (and friend? (piece? Rook) never-moved?) )
	   from
	   back ; K1
		 ; Save expensive not-attacked?s for last
	   (verify not-attacked?)
	   e ; KB1
	   (verify not-attacked?)
	   to
	   (set-attribute never-moved? false)
		 ; We could check if KN1 is attacked too, but this isn't
		 ; really necessary since Zillions doesn't allow any moves
		 ; into check
	   e ; KN1
	   (set-attribute never-moved? false)
	   add
	 )
)
(define O-O-O
     ( (verify never-moved?)
       w ; Q1
       (verify empty?)
       w ; QB1
       (verify empty?)
       cascade
       w ; QN1
       (verify empty?)
       w ; QR1
       (verify (and friend? (piece? Rook) never-moved?) )
       from
       back ; K1
         ; Save expensive not-attacked?s for last
       (verify not-attacked?)
       w ; Q1
       (verify not-attacked?)
       to
       (set-attribute never-moved? false)
         ; We could check if KN1 is attacked too, but this isn't
         ; really necessary since Zillions doesn't allow any moves
         ; into check
       w ; QB1
       (set-attribute never-moved? false)
       add
     )
)


; Games
; ************************************************************************

(game
   (title "MiniChess 5x5")
   (description "小棋盘国际象棋没有王车易位，且兵只能走一格。")
   (history "This setup was adopted by the AISE (Associazione Italiana
      Scacchi Eterodossi) in 1978.  Recent play has suggested the game is a
      draw with best play.")
   (strategy "Much of the strategy of orthodox chess is sound.  Pawns promote more
      quickly on the smaller board and passed pawns are more dangerous.  Because
      the boards are smaller, Knights are a little stronger relative to the other
      pieces, whose long range is a bit less useful than on the 8x8 board.  In
	  the 5x5 variants, careful Pawn play is especially critical to opening up
	  the position where you want it to be opened up.")

   (win-sound "Audio\\Orchestra_CF.wav")
   (loss-sound "Audio\\Orchestra_FC.wav")
   (click-sound "Audio\\Pickup.wav")
   (release-sound "Audio\\WoodThunk.wav")
   (players White Black)
   (turn-order White Black)
   (board-5x5)
   (board-setup
      (White (Weak-Pawn a2 b2 c2 d2 e2) (Knight d1) (Bishop c1) (Rook e1) (Queen b1) (King a1))
      (Black (Weak-Pawn a4 b4 c4 d4 e4) (Knight d5) (Bishop c5) (Rook e5) (Queen b5) (King a5))
   )

   (piece
      (name Weak-Pawn)
 	  (help "兵：向前移动1格，只能斜进1格吃子。可以在对方底线升变。")
      (description "兵\只能向前1格。兵吃子只能斜进1格吃。\若兵到达对方底线，必须升变为车马象后中的任意一个。")
      (image White "images\Chess\SHaag\wpawn.bmp" "images\Chess\wpawn.bmp"
             Black "images\Chess\SHaag\bpawn.bmp" "images\Chess\bpawn.bmp")
      (moves
         (Pawn-capture nw)
         (Pawn-capture ne)
         (Weak-Pawn-move)
      )
   )
   (piece
      (name Pawn)
	  (help "兵：开始时向前进1-2格，向前移动1格，只能斜进1格吃子。可以在对方底线升变。")
      (description "兵\在初始位置时，可以向前进1-2格，以后只能向前1格。兵吃子只能斜进1格吃。\若兵到达对方底线，必须升变为车马象后中的任意一个。\当对方兵挺进两格而与你的兵并列时，你可以斜进一格吃掉它。")
      (image White "images\Chess\SHaag\wpawn.bmp" "images\Chess\wpawn.bmp"
             Black "images\Chess\SHaag\bpawn.bmp" "images\Chess\bpawn.bmp")
      (moves
         (Pawn-capture nw)
         (Pawn-capture ne)
         (Pawn-move)
         (En-Passant e)
         (En-Passant w)
      )
   )
   (piece
      (name Knight)
	(help "马：跳日字，可越子，不蹩腿。")
      (description "马\马走类似“日”字，即从一个1x2的长方形一角走到对角，或先直移一步，然后再往那个方向斜移一步。马是国际象棋唯一一个可以越子移动的棋子。")
      (image White "images\Chess\SHaag\wknight.bmp" "images\Chess\wknight.bmp"
             Black "images\Chess\SHaag\bknight.bmp" "images\Chess\bknight.bmp")
      (moves
	     (shift2 n ne)
	     (shift2 n nw)
	     (shift2 s se)
	     (shift2 s sw)
	     (shift2 e ne)
	     (shift2 e se)
	     (shift2 w nw)
	     (shift2 w sw)
      )
   )
   (piece
      (name Bishop)
	  (help "象：走斜线，格数不限")
      (description "象\象走斜线，格数不限，不能越子。")
      (image White "images\Chess\SHaag\wbishop.bmp" "images\Chess\wbishop.bmp"
             Black "images\Chess\SHaag\bbishop.bmp" "images\Chess\bbishop.bmp")
      (moves
         (slide ne)
         (slide nw)
         (slide se)
         (slide sw)
      )
   )
   (piece
      (name Rook)
	  (help "车：直走，格数不限。")
      (description "车\车走横直均可，格数不限。不能越子。")
      (image White "images\Chess\SHaag\wrook.bmp" "images\Chess\wrook.bmp"
             Black "images\Chess\SHaag\brook.bmp" "images\Chess\brook.bmp")
      (attribute never-moved? true)
      (moves
         (rook-slide n)
         (rook-slide e)
         (rook-slide s)
         (rook-slide w)
      )
   )
   (piece
      (name Queen)
	  (help "后：八方向走，格数不限。")
      (description "后\后是国际象棋里威力最强大的棋子，它可以走横直斜八个方向，且不限格数。")
      (image White "images\Chess\SHaag\wqueen.bmp" "images\Chess\wqueen.bmp"
             Black "images\Chess\SHaag\bqueen.bmp" "images\Chess\bqueen.bmp")
      (moves
         (slide n)
         (slide e)
         (slide s)
         (slide w)
         (slide ne)
         (slide nw)
         (slide se)
         (slide sw)
      )
   )
   (piece
      (name King)
	  (help "王：横直斜走1格，被将死输。")
      (description "王\王走八方1格，但是任何时候都不能被吃。\小型国际象棋的王不允许王车易位。")
      (image White "images\Chess\SHaag\wking.bmp" "images\Chess\wking.bmp"
             Black "images\Chess\SHaag\bking.bmp" "images\Chess\bking.bmp")
      (moves
         (shift n)
         (shift e)
         (shift s)
         (shift w)
         (shift ne)
         (shift nw)
         (shift se)
         (shift sw)
      )
   )
   (loss-condition (White Black) (checkmated King) )
)


(variant
   (title "Baby Chess 5x5")
   (description "这是按标准规则，即有王车易位且兵在初始位置可以走两格的小型国象")
   (history "Martin Gardner proposed Minichess in Scientific American
       (March 1962, later reprinted in `The Unexpected Hanging and Other Mathematical
       Diversions` (1989)).  He wanted the smallest board where all normal Chess moves
       could be played.\\In its original form the White pieces were set across from their
	   Black counterparts.  In this version, which he introduced in 1989, a row of pieces
	   has been switched.  Is White or Black better in this game?")
   (board-5x5)
   (board-setup
      (White (Pawn a2 b2 c2 d2 e2) (Knight b1) (Bishop c1) (Rook a1) (Queen d1) (King e1))
      (Black (Pawn a4 b4 c4 d4 e4) (Knight d5) (Bishop c5) (Rook e5) (Queen b5) (King a5))
   )
   (piece
      (name King)
	 (help "王：横直斜走1格，被将死输。")
      (description "王\王走八方1格，但是任何时候都不能被吃。\王有王车易位的移动方式，即王可以向车方向移动两格，然后车越过王与王相邻。以下场合不可易位：\①王被将军；\②王或者车已经动过；\③王车之间的格子有棋子，或者空格可被对方攻击。")
      (image White "images\Chess\SHaag\wking.bmp" "images\Chess\wking.bmp"
             Black "images\Chess\SHaag\bking.bmp" "images\Chess\bking.bmp")
      (attribute never-moved? true)
      (moves
         (king-shift n)
         (king-shift e)
         (king-shift s)
         (king-shift w)
         (king-shift ne)
         (king-shift nw)
         (king-shift se)
         (king-shift sw)
         (O-O-O)
      )
   )
)

(variant
   (title "Opposing Bishops 5x5")
   (history "")
   (board-5x5)
   (board-setup
      (White (Weak-Pawn a2 b2 c2 d2 e2) (Knight d1) (Bishop e1) (Rook c1) (Queen b1) (King a1))
      (Black (Weak-Pawn a4 b4 c4 d4 e4) (Knight b5) (Bishop a5) (Rook c5) (Queen d5) (King e5))
   )
)

(variant
   (title "Knights vs. Bishops 5x5")
   (history "A little experiment by Jeff Mallett")
   (board-5x5)
   (board-setup
      (White (Weak-Pawn a2 b2 c2 d2 e2) (Rook a1) (Knight b1) (King c1) (Queen d1) (Knight e1))
      (Black (Weak-Pawn a4 b4 c4 d4 e4) (Rook a5) (Bishop b5) (King c5) (Queen d5) (Bishop e5))
   )
)

(variant (title "-"))

(variant
   (title "Petty Chess 5x6")
   (description "实际上，这是国际象棋的右半部分。本规则有王车易位且兵可以在初始位置移动两格。")
   (history "The first published miniature chess variant, invented by B. Walker Watson
      and published in September 1930 in a letter to `British Chess Magazine`.  Italian
      players in AISE have recently concluded that 5x5 chess is too drawish, and this 5x6
      variant is probably a better game.  Note that the bishops begin on opposite
      colors.  A recent commercial version, with a different array, has appeared under
      the trademark `Quickchess`.")
   (board-5x6)
   (board-setup
      (White (Pawn a2 b2 c2 d2 e2) (Knight d1) (Bishop c1) (Rook e1) (Queen a1) (King b1))
      (Black (Pawn a5 b5 c5 d5 e5) (Knight d6) (Bishop c6) (Rook e6) (Queen a6) (King b6))
   )
   (piece
      (name King)
	  (help "王：横直斜走1格，被将死输。")
      (description "王\王走八方1格，但是任何时候都不能被吃。\王有王车易位的移动方式，即王可以向车方向移动两格，然后车越过王与王相邻。以下场合不可易位：\①王被将军；\②王或者车已经动过；\③王车之间的格子有棋子，或者空格可被对方攻击。")
      (image White "images\Chess\SHaag\wking.bmp" "images\Chess\wking.bmp"
             Black "images\Chess\SHaag\bking.bmp" "images\Chess\bking.bmp")
      (attribute never-moved? true)
      (moves
         (king-shift n)
         (king-shift e)
         (king-shift s)
         (king-shift w)
         (king-shift ne)
         (king-shift nw)
         (king-shift se)
         (king-shift sw)
         (O-O)
      )
   )
)


(variant (title "-"))

(define Pawn2-add       (if (in-zone? promotion-zone) (add Knight Rook Queen) else add ) )
(define Weak-Pawn2-move (n  (verify empty?) (Pawn2-add)) )
(define Pawn2-capture   ($1 (verify enemy?) (Pawn2-add)) )
(variant
   (title "Los Alamos Chess 6x6")
   (description "小型国际象棋基本规则。另外，此布局没有象，兵也不可升变为象。")
   (history "An early chess computer, Maniac I, was programmed in 1956 to play this
      simplified variant of chess at the Los Alamos Scientific Laboratory.  The smaller
      board, lack of Bishops, absence of castling, and uniformity of Pawn moves made
      this game much more tractable than Chess.  When it beat a beginner, it was the
      first time a human had ever lost to a computer in a chess-like game.")
   (board-6x6)
   (board-setup
      (White (Weak-Pawn a2 b2 c2 d2 e2 f2) (Knight b1 e1) (Rook a1 f1) (Queen c1) (King d1))
      (Black (Weak-Pawn a5 b5 c5 d5 e5 f5) (Knight b6 e6) (Rook a6 f6) (Queen c6) (King d6))
   )
   (piece
      (name Weak-Pawn)
	  (help "兵：向前移动1格，只能斜进1格吃子。可以在对方底线升变。")
      (description "兵\只能向前1格。兵吃子只能斜进1格吃。\若兵到达对方底线，必须升变为车、马、或后中的任意一个。")
      (image White "images\Chess\SHaag\wpawn.bmp" "images\Chess\wpawn.bmp"
             Black "images\Chess\SHaag\bpawn.bmp" "images\Chess\bpawn.bmp")
      (moves
         (Pawn2-capture nw)
         (Pawn2-capture ne)
         (Weak-Pawn2-move)
      )
   )
)

(variant
   (title "Knights vs. Bishops 6x6")
   (history "A little experiment by Jeff Mallett.  In regular Chess, Bishops are considered
       in little better than Knights in most positions.  On a smaller board the Bishops'
	   usual advantage of travelling long distances is diminished.")
   (board-6x6)
   (board-setup
      (White (Weak-Pawn a2 b2 c2 d2 e2 f2) (Rook a1 f1) (Knight b1 e1) (Queen c1) (King d1))
      (Black (Weak-Pawn a5 b5 c5 d5 e5 f5) (Rook a6 f6) (Bishop b6 e6) (Queen c6) (King d6))
   )
)
